package cn.zhibang.sannuo.web.controller;

import cn.zhibang.sannuo.account.service.AAccountnumderService;
import cn.zhibang.sannuo.commons.model.Accountnumber;
import cn.zhibang.sannuo.commons.model.Menu;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author AdminController
 * @version 1.0.0
 * @ClassName AdminController.java
 * @Description TODO
 * @createTime 2021年03月30日 10:00:00
 */
@Controller
public class AdminController {

    @Resource
    private AAccountnumderService aAccountnumderService;

    @GetMapping("/login")
    public String login(){
        return "login";
    }

    @GetMapping("/index")
    public String index(Model model){
        Subject subject = SecurityUtils.getSubject();
        Accountnumber admin = (Accountnumber)subject.getPrincipal();
        List<Menu> menus = aAccountnumderService.selMenuMids(admin.getAccount());
        model.addAttribute("menus", menus);
        return "index";
    }
}
